<html>
<head><meta charset="utf-8"><title>How does PM work from a high-level POV? · t-compiler/wg-polymorphization · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/index.html">t-compiler/wg-polymorphization</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/How.20does.20PM.20work.20from.20a.20high-level.20POV.3F.html">How does PM work from a high-level POV?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="206493521"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/How%20does%20PM%20work%20from%20a%20high-level%20POV%3F/near/206493521" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/How.20does.20PM.20work.20from.20a.20high-level.20POV.3F.html#206493521">(Aug 10 2020 at 18:12)</a>:</h4>
<p>From the incr-comp WG chat:</p>
<blockquote>
<p>We do not virtualize function calls with polymorphization</p>
</blockquote>
<p>How does it work, then? <span class="user-mention" data-user-id="116107">@davidtwco</span> I have no idea what you did. </p>
<p>Should I go read your paper? I'm a CS almost-graduate and  sort of a jack of all trades, do you think I might have the knowledge? :3</p>



<a name="206494009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/How%20does%20PM%20work%20from%20a%20high-level%20POV%3F/near/206494009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/How.20does.20PM.20work.20from.20a.20high-level.20POV.3F.html#206494009">(Aug 10 2020 at 18:17)</a>:</h4>
<p>It isn’t that complicated, you’d understand it without a problem. Monomorphisation collection adds functions (and statics and other things) to a set of mono items. As a result, that means there will only be one entry for a function (invoked with the same generic parameters) from multiple callers. Polymorphization utilises this by detecting where the substitutions (the concrete types and constants corresponding to the generic params) could vary less (e.g. if a parameter is unused). In these cases, the substitutions are modified so that the mono item set does the deduplication for us and we give fewer copies of functions to LLVM.</p>



<a name="206494165"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/How%20does%20PM%20work%20from%20a%20high-level%20POV%3F/near/206494165" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/How.20does.20PM.20work.20from.20a.20high-level.20POV.3F.html#206494165">(Aug 10 2020 at 18:19)</a>:</h4>
<p>Other changes are necessary to ensure the compiler won’t bail out when it sees generic parameters where there previously hadn’t been any but that’s it in a nutshell.</p>



<a name="206494386"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/How%20does%20PM%20work%20from%20a%20high-level%20POV%3F/near/206494386" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/How.20does.20PM.20work.20from.20a.20high-level.20POV.3F.html#206494386">(Aug 10 2020 at 18:21)</a>:</h4>
<p>Ohhhh, I think I get it!</p>



<a name="206494454"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/How%20does%20PM%20work%20from%20a%20high-level%20POV%3F/near/206494454" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/How.20does.20PM.20work.20from.20a.20high-level.20POV.3F.html#206494454">(Aug 10 2020 at 18:22)</a>:</h4>
<p>Lemme see... so if I have f&lt;T&gt; which is a generic fn with a type parameter T</p>



<a name="206494510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/How%20does%20PM%20work%20from%20a%20high-level%20POV%3F/near/206494510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/How.20does.20PM.20work.20from.20a.20high-level.20POV.3F.html#206494510">(Aug 10 2020 at 18:22)</a>:</h4>
<p>And I use it twice in my code, inside two different functions - or even modules</p>



<a name="206494559"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/How%20does%20PM%20work%20from%20a%20high-level%20POV%3F/near/206494559" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/How.20does.20PM.20work.20from.20a.20high-level.20POV.3F.html#206494559">(Aug 10 2020 at 18:23)</a>:</h4>
<p>But in both of those instances I use the same exact instantiation of the function, let's say <code>f&lt;i32&gt;</code></p>



<a name="206494593"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/How%20does%20PM%20work%20from%20a%20high-level%20POV%3F/near/206494593" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/How.20does.20PM.20work.20from.20a.20high-level.20POV.3F.html#206494593">(Aug 10 2020 at 18:23)</a>:</h4>
<p><strong>then</strong> is when PM comes into play</p>



<a name="206494631"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/How%20does%20PM%20work%20from%20a%20high-level%20POV%3F/near/206494631" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/How.20does.20PM.20work.20from.20a.20high-level.20POV.3F.html#206494631">(Aug 10 2020 at 18:23)</a>:</h4>
<p>no</p>



<a name="206494635"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/How%20does%20PM%20work%20from%20a%20high-level%20POV%3F/near/206494635" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/How.20does.20PM.20work.20from.20a.20high-level.20POV.3F.html#206494635">(Aug 10 2020 at 18:23)</a>:</h4>
<p>Because rustc doesn't notice that they are the same, and actually instantiates the same function twice</p>



<a name="206494639"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/How%20does%20PM%20work%20from%20a%20high-level%20POV%3F/near/206494639" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/How.20does.20PM.20work.20from.20a.20high-level.20POV.3F.html#206494639">(Aug 10 2020 at 18:23)</a>:</h4>
<p>No?</p>



<a name="206494685"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/How%20does%20PM%20work%20from%20a%20high-level%20POV%3F/near/206494685" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/How.20does.20PM.20work.20from.20a.20high-level.20POV.3F.html#206494685">(Aug 10 2020 at 18:24)</a>:</h4>
<p>so two versions of<code>f&lt;i32&gt;</code> already work rn</p>



<a name="206494706"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/How%20does%20PM%20work%20from%20a%20high-level%20POV%3F/near/206494706" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/How.20does.20PM.20work.20from.20a.20high-level.20POV.3F.html#206494706">(Aug 10 2020 at 18:24)</a>:</h4>
<p>Kay</p>



<a name="206494709"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/How%20does%20PM%20work%20from%20a%20high-level%20POV%3F/near/206494709" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/How.20does.20PM.20work.20from.20a.20high-level.20POV.3F.html#206494709">(Aug 10 2020 at 18:24)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="k">fn</span> <span class="nf">f</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span><span class="p">{}</span><span class="w"> </span><span class="c1">// notice that T is unused</span>

<span class="c1">// both will give the same function with polymorphization</span>
<span class="n">f</span>::<span class="o">&lt;</span><span class="kt">u8</span><span class="o">&gt;</span><span class="p">();</span><span class="w"></span>
<span class="n">f</span>::<span class="o">&lt;</span><span class="kt">u16</span><span class="o">&gt;</span><span class="p">();</span><span class="w"></span>
</code></pre></div>



<a name="206494761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/How%20does%20PM%20work%20from%20a%20high-level%20POV%3F/near/206494761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/How.20does.20PM.20work.20from.20a.20high-level.20POV.3F.html#206494761">(Aug 10 2020 at 18:24)</a>:</h4>
<p>Polymorphization is when a param <code>T</code> is unused, or in the future only for example the size is used (grouping equal sizes), but not any methods.</p>



<a name="206494785"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/How%20does%20PM%20work%20from%20a%20high-level%20POV%3F/near/206494785" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/How.20does.20PM.20work.20from.20a.20high-level.20POV.3F.html#206494785">(Aug 10 2020 at 18:25)</a>:</h4>
<p>Ohh.</p>



<a name="206494801"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/How%20does%20PM%20work%20from%20a%20high-level%20POV%3F/near/206494801" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/How.20does.20PM.20work.20from.20a.20high-level.20POV.3F.html#206494801">(Aug 10 2020 at 18:25)</a>:</h4>
<p>Oh I see</p>



<a name="206494806"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/How%20does%20PM%20work%20from%20a%20high-level%20POV%3F/near/206494806" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/How.20does.20PM.20work.20from.20a.20high-level.20POV.3F.html#206494806">(Aug 10 2020 at 18:25)</a>:</h4>
<p>If you only instantiated the function once, with or without polymorphization then there’d be a single copy. If you instantiated it worth two different types and the function used the generic parameter, there would be two copies with or without polymorphization. If it is unused, then with polymorphization there would be a single copy.</p>



<a name="206494841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/How%20does%20PM%20work%20from%20a%20high-level%20POV%3F/near/206494841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/How.20does.20PM.20work.20from.20a.20high-level.20POV.3F.html#206494841">(Aug 10 2020 at 18:25)</a>:</h4>
<p>I see</p>



<a name="206494865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/How%20does%20PM%20work%20from%20a%20high-level%20POV%3F/near/206494865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/How.20does.20PM.20work.20from.20a.20high-level.20POV.3F.html#206494865">(Aug 10 2020 at 18:25)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="k">trait</span><span class="w"> </span><span class="n">Foo</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">foo</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="kt">usize</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="n">U</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Foo</span><span class="o">&lt;</span><span class="n">U</span><span class="o">&gt;</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">T</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">foo</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="kt">usize</span> <span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">std</span>::<span class="n">mem</span>::<span class="n">size_of</span>::<span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="206494920"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/How%20does%20PM%20work%20from%20a%20high-level%20POV%3F/near/206494920" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/How.20does.20PM.20work.20from.20a.20high-level.20POV.3F.html#206494920">(Aug 10 2020 at 18:25)</a>:</h4>
<p>Params are for example frequently unused when using closures, as a closure inherits all params from the parent, but may only depend on some of them.</p>



<a name="206495003"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/How%20does%20PM%20work%20from%20a%20high-level%20POV%3F/near/206495003" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/How.20does.20PM.20work.20from.20a.20high-level.20POV.3F.html#206495003">(Aug 10 2020 at 18:26)</a>:</h4>
<p>I understand now. This is sort of a subset of the idea of polimorphization I thought this was: basically using dynamic dispatch to run the specific case of the function for each T at runtime</p>



<a name="206495005"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/How%20does%20PM%20work%20from%20a%20high-level%20POV%3F/near/206495005" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/How.20does.20PM.20work.20from.20a.20high-level.20POV.3F.html#206495005">(Aug 10 2020 at 18:26)</a>:</h4>
<p>in this example <code>&lt;u32 as Foo&lt;()&gt;&gt;::foo()</code> and <code>&lt;u32 as Foo&lt;bool&gt;&gt;::foo()</code> are currently two distinct monomorphic instances</p>



<a name="206495019"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/How%20does%20PM%20work%20from%20a%20high-level%20POV%3F/near/206495019" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/How.20does.20PM.20work.20from.20a.20high-level.20POV.3F.html#206495019">(Aug 10 2020 at 18:26)</a>:</h4>
<p>will polymorphization, we can merge these two</p>



<a name="206495090"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/How%20does%20PM%20work%20from%20a%20high-level%20POV%3F/near/206495090" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/How.20does.20PM.20work.20from.20a.20high-level.20POV.3F.html#206495090">(Aug 10 2020 at 18:27)</a>:</h4>
<p>Ohhh!</p>



<a name="206495098"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/How%20does%20PM%20work%20from%20a%20high-level%20POV%3F/near/206495098" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/How.20does.20PM.20work.20from.20a.20high-level.20POV.3F.html#206495098">(Aug 10 2020 at 18:27)</a>:</h4>
<p>I see now</p>



<a name="206495119"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/How%20does%20PM%20work%20from%20a%20high-level%20POV%3F/near/206495119" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/How.20does.20PM.20work.20from.20a.20high-level.20POV.3F.html#206495119">(Aug 10 2020 at 18:27)</a>:</h4>
<p>With traits, this pattern pops up everywhere!</p>



<a name="206495174"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/How%20does%20PM%20work%20from%20a%20high-level%20POV%3F/near/206495174" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/How.20does.20PM.20work.20from.20a.20high-level.20POV.3F.html#206495174">(Aug 10 2020 at 18:28)</a>:</h4>
<p>traits and closures, yeah <span aria-label="sparkles" class="emoji emoji-2728" role="img" title="sparkles">:sparkles:</span></p>



<a name="206495227"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/How%20does%20PM%20work%20from%20a%20high-level%20POV%3F/near/206495227" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/How.20does.20PM.20work.20from.20a.20high-level.20POV.3F.html#206495227">(Aug 10 2020 at 18:28)</a>:</h4>
<p><span aria-label="heart" class="emoji emoji-2764" role="img" title="heart">:heart:</span> fuck yeah this is awesome</p>



<a name="206495258"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/How%20does%20PM%20work%20from%20a%20high-level%20POV%3F/near/206495258" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/How.20does.20PM.20work.20from.20a.20high-level.20POV.3F.html#206495258">(Aug 10 2020 at 18:28)</a>:</h4>
<p>iirc we want to also polymorphize stuff like <code>Vec&lt;T&gt;::len()</code> in the future</p>



<a name="206495346"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/How%20does%20PM%20work%20from%20a%20high-level%20POV%3F/near/206495346" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/How.20does.20PM.20work.20from.20a.20high-level.20POV.3F.html#206495346">(Aug 10 2020 at 18:29)</a>:</h4>
<p>Is <code>len()</code> dependent on <code>T</code> there?</p>



<a name="206495347"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/How%20does%20PM%20work%20from%20a%20high-level%20POV%3F/near/206495347" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/How.20does.20PM.20work.20from.20a.20high-level.20POV.3F.html#206495347">(Aug 10 2020 at 18:29)</a>:</h4>
<p>When the analysis becomes more advanced (as others mentioned, e.g. only the size of <code>T</code> is required) then it’ll work in more common situations.</p>



<a name="206495375"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/How%20does%20PM%20work%20from%20a%20high-level%20POV%3F/near/206495375" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/How.20does.20PM.20work.20from.20a.20high-level.20POV.3F.html#206495375">(Aug 10 2020 at 18:29)</a>:</h4>
<p>e.g. <code>&lt;u32 as Foo&lt;()&gt;&gt;::foo()</code> and <code>&lt;(u16, u16) as Foo&lt;()&gt;&gt;::foo()</code> in the above example</p>



<a name="206495420"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/How%20does%20PM%20work%20from%20a%20high-level%20POV%3F/near/206495420" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/How.20does.20PM.20work.20from.20a.20high-level.20POV.3F.html#206495420">(Aug 10 2020 at 18:29)</a>:</h4>
<p>Ahh, okay, I thought that case was implemented already :3</p>



<a name="206495452"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/How%20does%20PM%20work%20from%20a%20high-level%20POV%3F/near/206495452" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/How.20does.20PM.20work.20from.20a.20high-level.20POV.3F.html#206495452">(Aug 10 2020 at 18:30)</a>:</h4>
<p><code>len</code> uses <code>Vec&lt;T&gt;</code>, which makes it dependent on <code>T</code> rn, we don't detect that <code>len</code> never actually interacts with <code>T</code> atm</p>



<a name="206495505"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/How%20does%20PM%20work%20from%20a%20high-level%20POV%3F/near/206495505" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/How.20does.20PM.20work.20from.20a.20high-level.20POV.3F.html#206495505">(Aug 10 2020 at 18:30)</a>:</h4>
<p>I see</p>



<a name="206495550"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/How%20does%20PM%20work%20from%20a%20high-level%20POV%3F/near/206495550" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/How.20does.20PM.20work.20from.20a.20high-level.20POV.3F.html#206495550">(Aug 10 2020 at 18:30)</a>:</h4>
<p>Yo this is cool AF</p>



<a name="206495592"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/How%20does%20PM%20work%20from%20a%20high-level%20POV%3F/near/206495592" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Félix Fischer <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/How.20does.20PM.20work.20from.20a.20high-level.20POV.3F.html#206495592">(Aug 10 2020 at 18:31)</a>:</h4>
<p>And I learned something new today <span aria-label="grinning face with smiling eyes" class="emoji emoji-1f601" role="img" title="grinning face with smiling eyes">:grinning_face_with_smiling_eyes:</span></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>